
/**
 * Contains custom JavaScript Validation code For Employee Page
 */

function newformValidatorE() {
	
	var empId = $('#newUsername').val();
	var pass = $('#newPassword').val();
	var firstName = $('#newFirstName').val();
	var lastName = $('#newLastName').val();
	
	if(empId == '' || pass == '' || firstName == '' || lastName == '') {
		alert("All Fields Mandatory");
		return false;
	}
	if(!empId.match(/^[0-9]+$/)){
		alert("Employee Id should be numeric ONLY");
		return false;
	}
	if(!pass.match(/^[0-9a-zA-Z]+$/)){
		alert("Password should only be Alphanumeric");
		return false;
	}
	if(!firstName.match(/^[a-zA-Z]+$/) || !lastName.match(/^[a-zA-Z]+$/)){
		alert("Name should only contain Alphabets");
		return false;
	}
	return true;
}

function editformValidatorE(){
	var firstName = $('#editFirstName').val();
	var lastName = $('#editLastName').val();
	
	if(firstName == '' || lastName == '') {
		alert("All Fields Mandatory");
		return false;
	}
	if(!firstName.match(/^[a-zA-Z]+$/) || !lastName.match(/^[a-zA-Z]+$/)){
		alert("Name should only contain Alphabets");
		return false;
	}
	return true;
}

/**
 * Contains custom JavaScript Validation code For Project Page
 */
function newformValidatorP(){
	var prjId = $('#newProjectId').val();
	var prjName = $('#newProjectName').val();
	var prjStartDate = $('#newProjectStartDate').val();
	var prjEndDate = $('#newProjectEndDate').val();
	
	if(prjId == '' || prjName == '' || prjStartDate == '' || prjEndDate == '') {
		alert("All Fields Mandatory");
		return false;
	}
	if(!prjId.match(/^[0-9a-zA-Z]+$/)){
		alert("Project Id should be Alphanumeric");
		return false;
	}
	if(!prjName.match(/^[a-zA-Z]+$/) ){
		alert("Project name should only contain Alphabets");
		return false;
	}
	if(!prjStartDate.match(/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/) ){
		alert("Project Start Date should only be in date format");
		return false;
	}
	if(!prjEndDate.match(/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/) ){
		alert("Project End Date should only be in date format");
		return false;
	}
	return true;
}

function editformValidatorP(){
	var prjName = $('#editProjectName').val();
	var prjStartDate = $('#editProjectStartDate').val();
	var prjEndDate = $('#editProjectEndDate').val();
	
	if(prjName == '' || prjStartDate == '' || prjEndDate == '') {
		alert("All Fields Mandatory");
		return false;
	}
	if(!prjName.match(/^[a-zA-Z]+$/) ){
		alert("Project name should only contain Alphabets");
		return false;
	}
	if(!prjStartDate.match(/^([0-9]{2})-([0-9]{2})-([0-9]{4})$/) ){
		alert("Project Start Date should only be in date format");
		return false;
	}
	if(!prjEndDate.match(/^([0-9]{2})-([0-9]{2})-([0-9]{4})$/) ){
		alert("Project End Date should only be in date format");
		return false;
	}
	return true;
}

/**
 * Contains custom JavaScript Validation code For Training Page
 */

function newformValidatorT(){
	var trainingId = $('#newTrainingId').val();
	var trainingName = $('#newTrainingName').val();
	var trainingDescription = $('#newDescription').val();
	
	if(trainingId == '' || trainingName == '' || trainingDescription == '') {
		alert("All Fields Mandatory");
		return false;
	}
	if(!trainingId.match(/^[0-9a-zA-Z]+$/)){
		alert("Training Id should be Alphanumeric");
		return false;
	}
	if(!trainingName.match(/^[a-zA-Z]+$/) ){
		alert("Training name should only contain Alphabets");
		return false;
	}
	if(!trainingName.match(/^[a-zA-Z]+$/) ){
		alert("Training Description should only contain Alphabets");
		return false;
	}
	return true;
}

function editformValidatorT(){
	var trainingName = $('#editTrainingName').val();
	var trainingDescription = $('#editDescription').val();
	if(trainingName == '' || trainingDescription == '') {
		alert("All Fields Mandatory");
		return false;
		}
		if(!trainingName.match(/^[a-zA-Z]+$/) ){
			alert("Training name should only contain Alphabets");
			return false;
		}
		if(!trainingDescription.match(/^[a-zA-Z]+$/) ){
			alert("Training Description should only contain Alphabets");
			return false;
		}
		return true;
	
}
